#include <stdint.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include "module.h"
#include <stdint.h>
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>
#include <sys/select.h>
#include "keymgt.h"
#include <sys/err.h>

extern sys_api_t * sysapi;

int sec_key_injection( void )
{
	    return sysapi->sec_key_injection( );
}

int sec_crl_injection( void )
{
	    return sysapi->sec_crl_injection( );
}

int sec_get_keygrp_no( uint8_t *fid, uint8_t *gid )
{
	    return sysapi->sec_get_keygrp_no( fid, gid );
}

int sec_set_curr_keygrp( uint8_t fid, uint8_t gid )
{
	    return sysapi->sec_set_curr_keygrp( fid, gid );
}

int  sec_set_workkey( uint8_t fid, uint8_t gid, 
                            uint8_t type, sec_set_workkey_t *key_info )
{
        return sysapi->sec_set_workkey( fid, gid, type, key_info );
}
		
int sec_pin_encrypt( pin_block_type_t format, sec_pin_encrypt_t *info, 
					uint8_t * result)
{
	    return sysapi->sec_pin_encrypt( format, info, result );
}

int sec_mac_9606(uint8_t* in, uint32_t len, uint8_t *out)
{
	    return sysapi->sec_mac_9606( in, len, out );
}

int sec_mac_x99(uint8_t* in, uint32_t len, uint8_t *out)
{
	    return sysapi->sec_mac_x99( in, len, out );
}

int sec_mac_x919(uint8_t* in, uint32_t len, uint8_t *out)
{
	    return sysapi->sec_mac_x919( in, len, out );
}

int sec_track_encrypt( uint8_t *track_bcd, int len )
{
	    return sysapi->sec_track_encrypt( track_bcd, len );
}

int sec_track_cryptv( int type, sec_track_info_t *track_info )
{
	    return sysapi->sec_track_cryptv( type, track_info );
}

int sec_pin_cryptv( int type, pin_block_type_t format, sec_pin_info_t *info )
{
	    return sysapi->sec_pin_cryptv( type, format, info );
}

int sec_mac_cryptv( int type, sec_mac_info_t *mac_info )
{
	    return sysapi->sec_mac_cryptv( type, mac_info );
}

int sec_data_cryptv( int type, sec_data_info_t *data_info )
{
	    return sysapi->sec_data_cryptv( type, data_info );
}
int sec_mac_dc_ecb(uint8_t* in, int len, uint8_t *out)
{
	    return sysapi->sec_mac_dc_ecb( in, len, out );
}

int sec_unset_key( uint8_t fid, uint8_t gid, uint8_t type )
{
	    return sysapi->sec_unset_key( fid, gid, type );
}

int sec_set_masterkey( uint8_t gid, sec_set_masterkey_t *key_info )
{
	    return sysapi->sec_set_masterkey( gid, key_info );
}

int sec_update_masterkey( uint8_t gid, upt_masterkey_t *key_info )
{
	    return sysapi->sec_update_masterkey( gid, key_info );
}

int rsapublicfunc(uint8_t *output,uint32_t *outputLen,
                uint8_t *input, uint32_t inputLen,R_RSA_PUBLIC_KEY *publicKey )
{
	    return sysapi->rsapublicfunc( output, outputLen, input, inputLen, publicKey );
}


int sec_sm2_verify_signature( sm2_sign_t *sign, sm2_para_t *para )
{
	    return sysapi->sec_sm2_verify_signature( sign, para );
}

int sec_sm3_calc( uint8_t *in, int len, uint8_t *out )
{
	    return sysapi->sec_sm3_calc( in, len, out );
}
